package mysql

import (
	"go.uber.org/zap"
	"gorm.io/gorm"
	"week2d/models/global"
)

// 课程详情页
type GoodsDetailWeek2d struct {
	gorm.Model
	GoodsTitle  string  `gorm:"type:varchar(30);comment:课程标题;"`
	GoodsPrice  float64 `gorm:"type:decimal(10,2);comment:课程价格;"`
	GoodsAvatar string  `gorm:"type:varchar(255);comment:课程图片;"`
	UserMobile  string  `gorm:"type:char(11);comment:教练手机号;"`
}

// 查询详情
func GoodsDetail(goodsId int) GoodsDetailWeek2d {
	data := GoodsDetailWeek2d{
		Model: gorm.Model{ID: uint(goodsId)},
	}
	err := global.DB.First(&data).Error
	if err != nil {
		zap.S().Info("未查询到数据", err)
		return GoodsDetailWeek2d{}
	}
	return data
}

// 删除查询详情
func GoodsDelete(goodsId int) error {
	data := GoodsDetailWeek2d{
		Model: gorm.Model{ID: uint(goodsId)},
	}
	return global.DB.Delete(&data).Error

}
